package com.mifengs.mall.floor;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.annotation.ItemProviderTag;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.mifengs.mall.R;
import com.mifengs.mall.adapter.GridQuickAdapter;
import com.mifengs.mall.entity.AdvertBean;
import com.mifengs.mall.entity.FloorBean;
import com.mifengs.mall.util.ToIntentUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lihaoqi on 2018/4/16.
 */


@ItemProviderTag(
        viewType = FloorListAdapter.TYPE_NINETEEN,
        layout = R.layout.fragment_nineteen_floor
)
public class FloorNineteenItemProvider extends BaseItemProvider<FloorBean,BaseViewHolder> {

    private GridQuickAdapter mGridQuickAdapter;

    @Override
    public void convert(BaseViewHolder viewHolder, final FloorBean floorBean, final int position) {
        RecyclerView mRecyclerView =  viewHolder.getView(R.id.grid_list);
        mRecyclerView.setLayoutManager(new GridLayoutManager(mContext,2));
        mRecyclerView.setNestedScrollingEnabled(false);
        mGridQuickAdapter= new GridQuickAdapter(R.layout.item_floor_nineteen,floorBean.getAdverts(),mContext);
        mRecyclerView.setAdapter(mGridQuickAdapter);
        mGridQuickAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                AdvertBean adverts = floorBean.getAdverts().get(position);
                ToIntentUtil.toCommonIntent(adverts.getActionUrl(),mContext);
            }
        });

    }

    @Override
    public void onClick(BaseViewHolder helper, FloorBean floorBean, int position) {

    }

    @Override
    public boolean onLongClick(BaseViewHolder helper, FloorBean floorBean, int position) {
        return false;
    }


}
